package com.jinzhi.jzweb.controller;


import java.util.*;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.jzweb.domain.JazSignupGroupDO;
import com.jinzhi.jzweb.service.JazSignupGroupService;
import com.jinzhi.common.utils.Result;

/**
 * 
 * <pre>
 * 报名组别
 * </pre>
 * <small> 2024-09-05 15:21:59 | Long</small>
 */
@Controller
@RequestMapping("/jzweb/jazSignupGroup")
public class JazSignupGroupController extends BaseController {
	@Autowired
	private JazSignupGroupService jazSignupGroupService;
	
	@GetMapping()
	//@RequiresPermissions("jzweb:jazSignupGroup:jazSignupGroup")
	String JazSignupGroup(){
	    return "jzweb/jazSignupGroup/jazSignupGroup";
	}
	
	@ResponseBody
	@GetMapping("/list")
//	@RequiresPermissions("jzweb:jazSignupGroup:jazSignupGroup")
	public Result<List<JazSignupGroupDO>> list(){
		// 查询列表数据
		List<JazSignupGroupDO> jazSignupGroupDOS = jazSignupGroupService.selectList(null);
		return Result.ok(jazSignupGroupDOS);
	}
	
	@GetMapping("/add")
	@RequiresPermissions("jzweb:jazSignupGroup:add")
	String add(){
	    return "jzweb/jazSignupGroup/add";
	}

	@GetMapping("/edit/{id}")
	@RequiresPermissions("jzweb:jazSignupGroup:edit")
	String edit(@PathVariable("id") Long id,Model model){
		JazSignupGroupDO jazSignupGroup = jazSignupGroupService.selectById(id);
		model.addAttribute("jazSignupGroup", jazSignupGroup);
	    return "jzweb/jazSignupGroup/edit";
	}
	
	@Log("添加报名组别")
	@ResponseBody
	@PostMapping("/save")
	@RequiresPermissions("jzweb:jazSignupGroup:add")
	public Result<String> save( JazSignupGroupDO jazSignupGroup){
		jazSignupGroupService.insert(jazSignupGroup);
        return Result.ok();
	}
	
	@Log("修改报名组别")
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("jzweb:jazSignupGroup:edit")
	public Result<String>  update( JazSignupGroupDO jazSignupGroup){
		boolean update = jazSignupGroupService.updateById(jazSignupGroup);
		return update ? Result.ok() : Result.fail();
	}
	
	@Log("删除报名组别")
	@PostMapping( "/remove")
	@ResponseBody
	@RequiresPermissions("jzweb:jazSignupGroup:remove")
	public Result<String>  remove( Long id){
		jazSignupGroupService.deleteById(id);
        return Result.ok();
	}
	
	@Log("批量删除报名组别")
	@PostMapping( "/batchRemove")
	@ResponseBody
	@RequiresPermissions("jzweb:jazSignupGroup:batchRemove")
	public Result<String>  remove(@RequestParam("ids[]") Long[] ids){
		jazSignupGroupService.deleteBatchIds(Arrays.asList(ids));
		return Result.ok();
	}
	
}
